<template>
  <!-- 选择框 -->
  <view>
    <u-popup
      @close="close"
      border-radius="10"
      v-model="show"
      mode="center"
      length="80%"
      :mask="true"
      :closeable="true"
      :close-icon-pos="closeIconPos"
    >
      <view>
        <view class="cont">
          <view class="tit">选择招聘类型</view>
          <u-radio-group
            shape="square"
            width="50%"
            :wrap="false"
            v-model="kind"
            :activeColor="activeColor"
          >
            <u-radio
              @change="kindradioChange(item)"
              v-for="(item, index) in list2"
              :key="index"
              :name="item.name"
              >{{ item.name }}</u-radio
            >
          </u-radio-group>
          <view class="tit">选择分类</view>

          <u-radio-group
            shape="square"
            width="50%"
            :wrap="false"
            v-model="value"
            :activeColor="activeColor"
          >
            <u-radio
              @change="radioChange(item)"
              v-for="(item, index) in list1"
              :key="index"
              :name="item.name"
              >{{ item.name }}</u-radio
            >
          </u-radio-group>
          <u-button
            @click="cruit"
            class="go"
            type="primary"
            :ripple="true"
            ripple-bg-color="#909399"
            >确 定
          </u-button>
        </view>
      </view>
    </u-popup>
    <u-toast ref="uToast" />
  </view>
</template>
<script>
import api from "../api/routes.js";
export default {
  props: ["urls", "reload",'companyInfo'],
  data() {
    return {
      activeColor: "#2979ff",
      show: true,
      list1: [
        {
          name: "建筑招工",
          checked: false,
          code: "build",
        },
        {
          name: "装修",
          checked: false,
          code: "fitup",
        },
        {
          name: "能源",
          checked: false,
          code: "energy",
        },
        {
          name: "其他",
          checked: false,
          code: "other",
        },
      ],
      list2: [
        {
          name: "个人/班组",
          checked: false,
          code: "person",
        },
        {
          name: "企业",
          checked: false,
          code: "company",
        },
      ],
      type: "",
      closeIconPos: "top-right",
      value: "",
      kind: "",
      kindWord: "",
    };
  },
  methods: {
    close() {
      this.$emit("hideMask");
    },

    kindradioChange(e) {
      this.kindWord = e.code;
      console.log(e.code,"企业or个人");
    },

    radioChange(e) {
      this.type = e.code;
    },
   async cruit() {
      if (this.type && this.kindWord) {

        if (this.kindWord == "company") {
			  const res = await this.$myRequest({
				url: api.memberCertInfo,
				method: "GET",
				data: {},
			  });
          let { realnameState } = res.data.member;
          if (realnameState == 0) {
			this.$emit("hideMask");
          } else{
			console.log(2)
			this.$emit("weirenzheng");
			return
			}

          // this.$myRequest({
          // 	url: api.companyInfo,
          // 	method: "GET",
          // 	data: {},
          // }).then(res => {
          //   if(res.data.company.auditState!='已通过'){
          //     return
          //   }
          // })
        }
        uni.navigateTo({
          url: `${this.urls}?type=${this.type}&kindWord=${this.kindWord}&reload=${this.reload}&companyData=${this.companyInfo}`,
        });
      } else {
        this.$refs.uToast.show({
          title: "请选择招聘类型和分类!",
        });
      }
    },
  },
};
</script>
<style scoped lang="scss">
.cont {
  .tit {
    font-size: 28rpx;
    // text-align: center;
    padding: 20rpx;
    font-weight: bold;
    color: #333333;
  }

  padding: 60rpx 40rpx 40rpx;

  /deep/ .u-radio__label {
    width: 100%;
  }

  /deep/ .u-radio {
    margin-bottom: 25rpx;
  }

  .go {
    display: block;
    width: 100%;
    margin: 30rpx 0 0;
  }
}
</style>
